package com.ttg.common.utils;

import com.ttg.common.exception.BaseException;

import java.util.Objects;

/**
 * Description： int包装类比较工具
 * Author: chenyou
 * Date: 2025/8/26 9:29
 * Company: ttg
 * Copyright: Copyright (c) 2025
 */
public class IntegerUtil {

    public static boolean equals(Integer a,Integer b){
        return Objects.equals(a, b);
    }

    /**
     * 值a < 值b = true
     */
    public static boolean lt(Integer a,Integer b){
        if(a==null || b==null){
            throw new BaseException("比较值不能为空");
        }
        return a.compareTo(b)<0;
    }

    /**
     * 值a <= 值b = true
     */
    public static boolean lq(Integer a,Integer b){
        if(a==null || b==null){
            throw new BaseException("比较值不能为空");
        }
        return a.compareTo(b)<=0;
    }

    /**
     * 值a > 值b = true
     */
    public static boolean gt(Integer a,Integer b){
        if(a==null || b==null){
            throw new BaseException("比较值不能为空");
        }
        return a.compareTo(b)>0;
    }

    /**
     * 值a >= 值b = true
     */
    public static boolean ge(Integer a,Integer b){
        if(a==null || b==null){
            throw new BaseException("比较值不能为空");
        }
        return a.compareTo(b)>=0;
    }


    public static void main(String[] args) {
        System.out.println(equals(null,null));
        System.out.println(equals(null,1));
        System.out.println(equals(1,null));
        System.out.println(equals(1,1));
        System.out.println(equals(1,2));
        System.out.println("======================");

        System.out.println(lt(1,2));
        System.out.println(lt(2,2));
        System.out.println(lt(2,1));
        System.out.println("======================");

        System.out.println(gt(1,2));
        System.out.println(gt(2,2));
        System.out.println(gt(2,1));
    }
}
